/*
 * ECARX Technology Limited is the owner of the copyright and the trade secret of this software.
 * Without permission, no one has the right to obtain, disclose or use this software in any way.
 */

package com.ecarx.systemui.plugin.ui.custom;

import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.widget.FrameLayout;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.ecarx.systemui.plugin.model.listener.DispatchTouchEventCallback;
import com.ecarx.systemui.plugin.model.listener.GestureCallback;

public class DispatchTouchFrameLayout extends FrameLayout implements GestureCallback {

    private DispatchTouchEventCallback mEventCall;

    public DispatchTouchFrameLayout(@NonNull Context context) {
        super(context);
    }

    public DispatchTouchFrameLayout(@NonNull Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }

    public DispatchTouchFrameLayout(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }


    @Override
    public void setDispatchTouchEventCall(DispatchTouchEventCallback call) {
        this.mEventCall = call;
    }

    @Override
    public boolean dispatchTouchEvent(MotionEvent ev) {
        if (mEventCall != null){
            mEventCall.dispatchTouch(ev);
        }
        return super.dispatchTouchEvent(ev);
    }
}
